package org.ezplatform.office.forum.dao;

import java.util.List;

import org.ezplatform.core.dao.jpa.JpaBaseDao;
import org.ezplatform.office.forum.entity.ForumPostLabel;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/** 
 * 论坛标签
* @author 作者: wujs
* @version 创建时间：2018年12月5日 上午11:43:36 
* 类说明 
*/
@Repository
public interface ForumPostLabelDao extends JpaBaseDao<ForumPostLabel,String>{
	
	@Query(" from ForumPostLabel where postId = ?1  ")
	List<ForumPostLabel> getPostLabelByPost(String postId);
	
	@Query("select labelId from ForumPostLabel where postId = ?1  ")
	List<String> getLabelIdByPost(String postId);
	
	@Query("select postId from ForumPostLabel where postId in (?1) and labelId =?2 ")
	List<String> getPostIdByPostLabel(List<String> list,String labelId);
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from  oa_forum_post_label  where post_id in (?1) and label_id = ?2")
	int delByPostLabel(List<String> postIdlist,String labelId);
	
	@Modifying
	@Query(nativeQuery = true, value = "delete from  oa_forum_post_label  where post_id  = ?1")
	int delByPost(String postId);

}
